<template>
  <div>
    <div style="width: 100%;text-align: right">
      <el-button size="mini" type="primary" @click="addContact">
        <i class="el-icon-plus"/>
        新建联系人
      </el-button>
    </div>
    <el-table :data="contactsData" v-loading="loading" style="width: 100%;margin-top: 8px">
      <el-table-column show-overflow-tooltip align="center" min-width="155" label="姓名" prop="name"/>
      <el-table-column show-overflow-tooltip align="center" min-width="115" label="手机" prop="mobile"/>
      <el-table-column show-overflow-tooltip align="center" min-width="175" label="邮箱" prop="email"/>
      <el-table-column show-overflow-tooltip align="center" min-width="135" label="职务" prop="post"/>
      <el-table-column show-overflow-tooltip align="center" min-width="155" label="是否关键决策人"
                       prop="decisionStatus"
      >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_crm_decision" :value="scope.row.decisionStatus"/>
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip align="center" min-width="135" label="操作">
        <template scope="scope">
          <el-button type="text" @click="primaryContactHandler(scope.row)" v-if="scope.row.decisionStatus == 1">
            设置首要联系人
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: 'ContactsDrawerTable',
  components: {},
  dicts: ['sys_crm_decision'],
  props: {
    contactsData: {
      type: Array
    },
    loading: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {}
  },
  // 在实例创建完成后被立即调用
  created() {

  },
  // 实例被挂在后调用
  mounted() {

  },
  // 方法
  methods: {
    // 设置首要联系人
    primaryContactHandler(row) {
      this.$emit('setPrimaryContact', row.id)
    },
    // 添加联系人
    addContact() {
      this.$emit('addContact')
    }
  }
}
</script>

<style scoped>

</style>
